package com.dianwoba.pt.goodjob.schedule.intern;

import com.dianwoba.pt.goodjob.common.utils.JsonMapper;
import com.dianwoba.pt.goodjob.schedule.util.SpringContextHolder;
import com.dianwoba.pt.goodjob.schedule.util.ThreadUtil;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by xuanwu on 16/3/23.
 */
//@DisallowConcurrentExecution是否禁止并行模式
public class WacQuartzJob extends AbstractQuartzJob {

    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("================async job execute==================");
        Map<String, Object> contextMap = new HashMap<>();
        Long nextFireTime = jobExecutionContext.getNextFireTime().getTime();
        Long schedTime = jobExecutionContext.getScheduledFireTime().getTime();
        contextMap.put("taskId", jobExecutionContext.getMergedJobDataMap().get("taskId"));
        contextMap.put("taskName", jobExecutionContext.getMergedJobDataMap().get("taskName"));
        contextMap.put("execType", jobExecutionContext.getMergedJobDataMap().get("execType"));
        contextMap.put("preFireTime", schedTime);
        contextMap.put("nextFireTime", nextFireTime);

        jobExecute(contextMap);
    }
}
